﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <%=ViewData["SiteName"] %>
    -
    <%=ViewData["PageTitle"]%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="contentpage-outerdiv">
        <%= Html.ValidationSummary() %>
        <% using (Html.BeginForm())
           { %>
        <h2>
            Edit User</h2>
        <br />
        <% 
            MembershipUser membershipUser = (MembershipUser)ViewData["membershipUser"]; 
           
        %>
        <p>
            <b>UserName:</b>
            <%= membershipUser.UserName %>
        </p>
        <p>
            <b>E-Mail:</b>
            <%= membershipUser.Email %></p>
        <p>
            <b>Registered:</b>
            <%= membershipUser.CreationDate.ToLocalTime() %></p>
        <p>
            <b>Last Login:</b>
            <%= membershipUser.LastLoginDate.ToLocalTime() %></p>
        <p>
            <b>Last Activity:</b>
            <%= membershipUser.LastActivityDate.ToLocalTime() %></p>
        <p>
            <b>Online Now:</b>
            <%= Html.CheckBox("onlineNow", membershipUser.IsOnline, new { disabled = "true" })%></p>
        <p>
            <b>Approved:</b>
            <%= Html.CheckBox("approved", membershipUser.IsApproved)%></p>
        <p>
            <b>Locked Out:</b>
            <%= Html.CheckBox("lockedOut", membershipUser.IsLockedOut)%></p>
        <hr />
        <h2>
            Edit User Roles</h2>
        
            <% foreach (String role in (String[])ViewData["roles"])
               {%>
               <p>
               <%    
                   if (role != "PortalAdmin" && role != "Admin")
                   {
            %>            
            <%= Html.CheckBox("role." + role, Roles.IsUserInRole(ViewData["id"].ToString(), role))%>
            <%= role.ToString()%>
            <% 
                }
               else
               {
                   if (role == "PortalAdmin" && Roles.IsUserInRole("PortalAdmin"))
                   {

                   }
                   else if (role == "Admin" && (Roles.IsUserInRole("Admin") || Roles.IsUserInRole("PortalAdmin")))
                   {
            %>
            <%= Html.CheckBox("role." + role, Roles.IsUserInRole(ViewData["id"].ToString(), role))%>
            <%= role.ToString()%>
            <% 
                   }

               }%>
           </p>        
         <%} %>
        
        <p>
            <button type="submit" id="user-editUser-button">
                Update User</button>
            &nbsp;&nbsp;
            <button type="button" onclick="location.href='/Account/ManageUsers'">
                Return</button></p>
        <%= Html.Hidden("id",ViewData["id"]) %>
        <% } %>
    </div>
</asp:Content>
